define(['./config'], () => {
    class Tab {
        constructor() {
           
            this.detail = document.querySelector('.produce-container')
            this.inint()
        }
        inint() {

            this.request()

        }
        queryStr(gameid) {
            let str = location.search
            let obj = {}
            let arr = str.split('?')[1]
            arr = arr.split('&')
            arr.forEach(item => {
                let newArr = item.split('=')
                obj[newArr[0]] = newArr[1]

            })

            return obj.id

        }
        request() {
            let id = this.queryStr('id')

            pAjax({
                    url: '../data/produce1.json'
                })
                .then(res => {
                    let data = JSON.parse(res)
                    console.log(data);
                    data.forEach(item => {

                        if (item.id == id) {
                            this.resert(item)
                        }
                    })





                })
        }
        resert(cc) {
            console.log(cc);
            let Arr = [cc]


            Arr.forEach((item) => {
                this.detail.innerHTML += `
                <div class="main-wrap">
                <div class="produce-top">
                    <div class="pro-top-main">
                        <div class="image"></div>
                    </div>
                    <div class="game-info">
                        <div class="main">
                            <div class="main-left">
                                <div class="left-icon"></div>
                                <div class="main-right">
                                    <div class="name">
                                        <span>${item.name}</span>
                                    </div>
                                    <div class="name-box">
                                        <div class="ename">${item.enname}</div>
                                        <div class="plat-tags">
                                            <div class="type plat">Switch</div>
                                            <div class="type plat">PS</div>
                                            <div class="type plat">Xbox</div>
                                            <div class="type tags">单机</div>
                                            <div class="type tags">策略经营</div>
                                        </div>
                                        <div class="desc">${item.des}</div>
                                    </div>
                                </div>
                            </div>
                            <div class="main-right">
                                <div class="right-button">
                                    <a href="#" class="disable">
                                        <div class="lw-btn">
                                            <div class="button-body">
                                                <div class="button-body-main">
                                                    <span class="button-buy"></span>
                                                    立即购买
                                                    <div class="buy-container">
                                                        <span class="button-price">
                                                            ￥${item.price}
                                                        </span>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="main-bottom">
                <div class="content">
                    <div class="detail">
                        <div class="game-banner-lunbo">
                            <div class="myvideo">
                                <video class="video" autoplay muted preload controls="controls">
                                    <source src="${item.video}" type="video/mp4">
                                </video>
                            </div>
                        </div>
                        <div class="wenzibox">
                            <div class="wenziheader">
                                <div class="header-title">游戏百科</div>
                            </div>
                        </div>
                        <div class="content-bottom">
                            <div class="content-resert">
                                <p class="resert1">${item.content1}</p>
                            </div>
                            <div class="tittle1">${item.title1}</div>
                            <div class="myimg1">
                                <img src="${item.content2}">
                            </div>
                            <div class="tittle1 tittle2">${item.title4}</div>
                            <div class="content-resert re1">
                                <p class="resert1 re2">${item.content7}</p>
                            </div>
                            <div class="tittle1 tittle2 tittle3">${item.title3}</div>
                            <div class="content-resert re2">
                                <p class="resert1 re3">${item.content4}</p>
                            </div>
                            <div class="myimg1 img2">
                                <img src="${item.content5}" alt="">
                            </div>
                            <div class="myimg1 img2 img3">
                                <img src="${item.content6}" alt="">
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            `
            })

        }
    }
    return Tab

})